package com.zhoug.zmuidemo.ui;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.ImageView;
import android.widget.Toast;

import com.zhoug.zmui.ZMUISearchView;
import com.zhoug.zmuidemo.R;

public class SearchViewActivity extends AppCompatActivity {

    private ZMUISearchView mSearchView;
    private ZMUISearchView mSearchView2;
    private ZMUISearchView mSearchViewRight;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_search_view);
        findViews();

        mSearchView.setOnSearchListener(s->{
            Toast.makeText(this, s, Toast.LENGTH_SHORT).show();
        });

        mSearchViewRight.setOnSearchListener(s->{
            Toast.makeText(this, s, Toast.LENGTH_SHORT).show();
        });
        ImageView rightImage1 = mSearchViewRight.getRightImage();
        rightImage1.setClickable(true);
        rightImage1.setOnClickListener(v->mSearchViewRight.startSearch());


        mSearchView2.setOnSearchListener(s->{
            Toast.makeText(this, s, Toast.LENGTH_SHORT).show();
        });
        ImageView rightImage = mSearchView2.getRightImage();
        rightImage.setClickable(true);
        rightImage.setOnClickListener(v->{
            Toast.makeText(this, "2:单击右边的图片", Toast.LENGTH_SHORT).show();
        });
    }

    private void findViews() {
        mSearchView = findViewById(R.id.searchView);
        mSearchView2 = findViewById(R.id.searchView2);
        mSearchViewRight = findViewById(R.id.searchView_right);
    }
}